package com.example.park_2306.date

import com.example.base.mvi.BaseViewModel
import com.example.base.mvi.HttpType
import com.example.base.room.DateDao
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.flow
import javax.inject.Inject
@HiltViewModel
class DateViewModel @Inject constructor(val dateDao: DateDao):BaseViewModel<DateIntent>() {
    override fun handleIntent(it: DateIntent) {
        when(it){
            is DateIntent.insert -> {
                roomRequest(flow { emit(dateDao.insert(it.item)) },HttpType.DEFAULT)
            }
            DateIntent.query -> {
                roomRequest(flow { emit(dateDao.query()) },HttpType.DETAIL)
            }
        }
    }
}